package com.itheima.pattern.iterator;

import java.util.List;

//迭代器
public class StudentIteratorImpl implements StudentIterator{
    private List<Student> list;
    private int position=0;//用来记录遍历时的位置

    public StudentIteratorImpl(List<Student> list){
        this.list=list;
    }


    //是否还有元素
    @Override
    public boolean hasNext() {
        return position<list.size();
    }

    @Override
    public Student next() {
        Student currstudent = list.get(position);
        position++;
        return currstudent;
    }
}
